function get_first_img_by_tid($tid){
	 $firstpid=thread_read($tid)['firstpid'];
	 $arr=attach_find_by_pid($firstpid);
	 if(empty($arr[1][0]['url'])){
		 return '';
	 }else{
		 return $arr[1][0]['url'];
	 } 
}

function get_first_img_by_pid($pid){
	 $arr=attach_find_by_pid($pid);
	if(empty($arr[1][0]['url'])) return '';
	 else return $arr[1][0]['url'];
}

function get_fenci_header($tid){
	$res=thread__read($tid)['keywords'];
    $arr=json_decode($res,1);
	$text="";
	foreach($arr as $val){
		$text.=$val."_";
	}
	return $text;

}

function get_fenci_tag($tid){
	$res=thread__read($tid)['keywords'];
    $arr=json_decode($res,1);
	$html="";
	foreach($arr as $val){
		$html.='<a href="/tag?keyboard='.$val.'" >'.$val.'</a>';
	}
	return $html;
}

function get_fenci_arr($tid){
	$res=thread__read($tid)['keywords'];
    $arr=json_decode($res,1);
	$html="";
	foreach($arr as $val){
		$html.='<a href="/tag?keyboard='.$val.'" >'.$val.'</a>';
	}
	return $html;
}

function fenci($str){
		$res=http_get("http://api.pullword.com/get.php?source={$str}&param1=0&param2=0&json=1");
	if(empty($res)){
		$res=http_get("http://114.67.84.223/get.php?source={$str}&param1=0&param2=0&json=1");
	}	
	if(empty($res)){
		$res=http_get("http://120.26.6.172/get.php?source={$str}&param1=0&param2=0&json=1");
	}	
	if(empty($res)){
		$res=http_get("http://116.196.101.207/get.php?source={$str}&param1=0&param2=0&json=1");
	}
    $arr=json_decode($res,1);
	$data=array();
	$i=0;
	foreach($arr as $val){
	    if($i>10)  break;
	    if(empty($val['t'])) continue;
		$keyboard=$val['t'];
		array_push($data,$keyboard);
	}
	return json_encode($data);
}